package org.giovanolli.mumi.entities;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.ForeignKey;

/**
 * The Class Specialist.
 */
@Entity
@Table(name = "specialist")
public class Specialist extends Person {

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 6499035374545138415L;

	/** The specialities. */
	@ManyToMany(cascade = { CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
	@JoinTable(name = "specialist_specialities", joinColumns = @JoinColumn(name = "specialist_id"), inverseJoinColumns = @JoinColumn(name = "speciality_id"))
	@ForeignKey(name = "fk_specialist_speciality_specialist", inverseName = "fk_specialist_speciality_speciality")
	private List<Speciality> specialities = new ArrayList<Speciality>();

	/** The skills. */
	@ManyToMany(cascade = { CascadeType.DETACH, CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH })
	private List<Skill> skills;

	/** The titles. */
	@OneToMany(cascade = CascadeType.ALL)
	@JoinColumn(name = "specialist_id", updatable = false, insertable = false, nullable = false)
	private List<SpecialistTitle> titles;
	
	/** The fees. */
	@OneToMany(cascade = CascadeType.ALL)
	@JoinColumn(name = "specialist_id")
	private List<SpecialistFee> fees;

	/** The attention time duration. */
	@Column(name = "attention_time_duration")
	private Integer attentionTimeDuration;
	
	/** The default fee. */
	@OneToOne(cascade = CascadeType.ALL)
	private SpecialistFee defaultFee;

	/**
	 * Instantiates a new specialist.
	 */
	public Specialist() {
		super();
		skills = new ArrayList<Skill>();
		fees = new ArrayList<SpecialistFee>();
		defaultFee = new SpecialistFee();
		defaultFee.setSpecialist(this);
	}

	/**
	 * Gets the attention time duration.
	 * 
	 * @return the attention time duration
	 */
	public Integer getAttentionTimeDuration() {
		return attentionTimeDuration;
	}

	/**
	 * Gets the fees.
	 * 
	 * @return the fees
	 */
	public List<SpecialistFee> getFees() {
		return fees;
	}

	/**
	 * Gets the skills.
	 * 
	 * @return the skills
	 */
	public List<Skill> getSkills() {
		return skills;
	}

	/**
	 * Gets the specialities.
	 * 
	 * @return the specialities
	 */
	public List<Speciality> getSpecialities() {
		return specialities;
	}

	/**
	 * Gets the titles.
	 * 
	 * @return the titles
	 */
	public List<SpecialistTitle> getTitles() {
		return titles;
	}

	/**
	 * Sets the attention time duration.
	 * 
	 * @param attentionTimeDuration
	 *            the new attention time duration
	 */
	public void setAttentionTimeDuration(Integer attentionTimeDuration) {
		this.attentionTimeDuration = attentionTimeDuration;
	}

	/**
	 * Sets the fees.
	 * 
	 * @param fees
	 *            the new fees
	 */
	public void setFees(List<SpecialistFee> fees) {
		this.fees = fees;
	}

	/**
	 * Sets the skills.
	 * 
	 * @param skills
	 *            the new skills
	 */
	public void setSkills(List<Skill> skills) {
		this.skills = skills;
	}

	/**
	 * Sets the specialities.
	 * 
	 * @param specialities
	 *            the new specialities
	 */
	public void setSpecialities(List<Speciality> specialities) {
		this.specialities = specialities;
	}

	/**
	 * Sets the titles.
	 * 
	 * @param titles
	 *            the new titles
	 */
	public void setTitles(List<SpecialistTitle> titles) {
		this.titles = titles;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.osoftware.mumi.dao.model.Person#toString()
	 */
	@Override
	public String toString() {
		return "Specialist [" + " titles=" + titles + ", toString()=" + super.toString() + "]";
	}

	/**
	 * Gets the default fee.
	 *
	 * @return the default fee
	 */
	public SpecialistFee getDefaultFee() {
		return defaultFee;
	}

	/**
	 * Sets the default fee.
	 *
	 * @param defaultFee the new default fee
	 */
	public void setDefaultFee(SpecialistFee defaultFee) {
		this.defaultFee = defaultFee;
	}
}
